package com.deft.design.flyweight.util;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Hide丶love
 * @date 2022/05/06
 **/
public class RedisUtils {

    private ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(1);

    private AtomicInteger stock = new AtomicInteger(0);

    public RedisUtils() {
        scheduledExecutorService.scheduleWithFixedDelay(() -> {
            stock.addAndGet(1);
        }, 0, 10000, TimeUnit.MILLISECONDS);
    }

    public int getStockUsed() {
        return stock.get();
    }
}
